import { createRouter, createWebHashHistory } from 'vue-router'
import HomeView from '../views/Home.vue'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      meta: {
        title: 'pdf转换器'
      },
      component: HomeView
    },
    {
      path: '/about',
      name: 'about',
      meta: {
        title: '关于'
      },
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/About.vue')
    },
    {
      path: '/outputManage',
      name: 'outputManage',
      meta: {
        title: '输出路径'
      },
      component: () => import('../views/OutputManage.vue')
    },
    {
      path: '/pdfToImg',
      name: 'pdfToImg',
      meta: {
        title: 'pdf转图片'
      },
      component: () => import('../views/PdfToImg.vue')
    },
    {
      path: '/pdfToDoc',
      name: 'pdfToDoc',
      meta: {
        title: 'pdf转word'
      },
      component: () => import('../views/PdfToDoc.vue')
    },
    {
      path: '/pptToPdf',
      name: 'pptToPdf',
      meta: {
        title: 'ppt转pdf'
      },
      component: () => import('../views/PptToPdf.vue')
    },
    {
      path: '/wordToPdf',
      name: 'wordToPdf',
      meta: {
        title: 'word转pdf'
      },
      component: () => import('../views/WordToPdf.vue')
    },
    {
      path: '/excelToPdf',
      name: 'excelToPdf',
      meta: {
        title: 'excel转pdf'
      },
      component: () => import('../views/ExcelToPdf.vue')
    },
    {
      path: '/extractResources',
      name: 'extractResources',
      meta: {
        title: '提取pdf资源'
      },
      component: () => import('../views/ExtractResources.vue')
    },
    {
      path: '/compress',
      name: 'compress',
      meta: {
        title: 'pdf压缩'
      },
      component: () => import('../views/Compress.vue')
    }
  ]
})
// @ts-ignore
router.beforeEach((to, from, next) => {
  window.document.title = to.meta.title as string
  next()
})

export default router
